<?php
namespace app\admin\service;
use app\admin\traits\ServiceTrait;

class RoleService
{
    //仓库
    public static $repository = 'app\repository\RoleRepository';

    use ServiceTrait;

    /**
     * 通过role_id构建前端路由
     * @param $role_info <Array> [{name:'角色1',role_id:1}]
     */
    public static function generateRouterByRoleInfo($role_info){
        $role_ids = [];
        array_walk_recursive($role_info, function($value) use(&$role_ids){
            array_push($role_ids, $value['role_id']);
        });
        return self::$repository::getPagesByIDs($role_ids);
    }
}